package view.toolboxComponents;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JLabel;
import controller.CustomEvent;
import controller.EventHandler;
import controller.ToolBoxEventHandler;
import model.Prescription;
/** * A class to encapsulate the prescription background panel contents * @author Daniel Bond, Mohammed Abdullah, Gideon Pyzer */
@SuppressWarnings("serial")
public class PrescriptionBackgroundPanel extends AbstractPanel{	private JLabel lblBGColour;
	private JButton btnBackgroundColour;
	private EventHandler eventHandler;

	public PrescriptionBackgroundPanel(){
	
		super();
		btnBackgroundColour = new JButton();
		lblBGColour = new JLabel("Colour");
		btnBackgroundColour.setMaximumSize(new Dimension(12, 12));
		btnBackgroundColour.setBackground(Prescription.getInstance().getBGColour());
		btnBackgroundColour.setToolTipText("Background colour of Prescription");
		buildPanel();
		btnBackgroundColour.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				CustomEvent event = new CustomEvent("bgColorChange", PrescriptionBackgroundPanel.this);
				PrescriptionBackgroundPanel.this.eventHandler = new ToolBoxEventHandler();
				eventHandler.createEvent(event);
			}
		});
	}	/**	 * Sets the button background colour	 * @param c the {@link java.awt.Color} object to set as the background colour	 */
	public void setButtonBackgroundColour(Color c){
		btnBackgroundColour.setBackground(c);
	}
	
	/**
	 * Build background panel
	 */
	private void buildPanel() {
		this.add(lblBGColour);
		makeRigidArea();
		this.add(btnBackgroundColour);
	}	
	@Override
	public void resetComponent() {
	}
}